package cn.redragon.soa.common.amqp.model;



import static cn.redragon.soa.common.constant.Constants.MQ.BRAND;
import static cn.redragon.soa.common.constant.Constants.MQ.SOURCE;

import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import org.apache.commons.lang3.StringUtils;

@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class CommonIdentity implements Identity {

    private String brand;
    private String source;

    private int delay = 0;

    @Override
    public Map<String, Object> getIdentity() {
        if (StringUtils.isNotBlank(source)) {
            return Map.of(BRAND, this.brand, SOURCE, this.source);
        }
        return Map.of(BRAND, this.brand);
    }

    @Override
    public int getDelayMs() {
        return delay;
    }
}